/**
 * 文件名称:PageSeparateTap.java
 * 文件版权:ChinaParasol Technologies Co., Ltd. Copyright 1998-2020, All rights reserved
 * 文件描述:<描述>
 * 修改作者:LiXiangDong
 * 修改时间:Jan 15, 2013
 */
package com.sunshade.common.page;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 * 
 * @author  LiXiangDong
 * @version V1.0
 */
public class PageSeparateTap extends SimpleTagSupport
{
    /**
     * 总页数<br>
     */
    private String totalPage = "";
    
    /**
     * 每页显示的记录数 <br>
     */
    private String pageSize = "10";
    
    /**
     * 当前的页数<br>
     */
    private String currentPage = "";
    
    /**
     * 默认的选择页数<br>
     */
    private String selectPage = "10";
    
    private String actionName = "";
    
    private String methodName = "";
    
    /**
     * 表单名字<br>
     */
    private String formName = "";
    
    public void doTag() throws JspException, IOException
    {
        JspWriter out = getJspContext().getOut();
        StringBuffer outStr = new StringBuffer(24);
        /*
        outStr.append("<span align='center'>单页记录数：&nbsp;<INPUT  TYPE='text' VALUE='"
                + pageSize + "' id='size' align = 'center'");
        outStr.append(" size='2' maxlength='6' onkeypress='onPressPageSize(this.value,"
                + "\""
                + actionName
                + "\",\""
                + methodName
                + "\",\""
                + formName
                + "\")' onblur='publicCheckPageCount(this);'></span>&nbsp;&nbsp;&nbsp;");
        */
        int totalPageInt = 0;
        
        if (totalPage != null && !"".equals(totalPage))
        {
            totalPageInt = Integer.parseInt(totalPage);
        }
        int currentPageInt = 0;
        
        if (currentPage != null && !"".equals(currentPage))
        {
            currentPageInt = Integer.parseInt(currentPage);
        }
        if (totalPageInt > 0)
        {
            outStr.append("<span style='cursor:hand'");
            outStr.append(">");
            
            if (currentPageInt == 1)
            {
                outStr.append("<font color='#BBBBBB' size = '2'>");
            }
            else
            {
                outStr.append("<a href='javascript:goPage(1," + "\""
                        + actionName + "\",\"" + methodName + "\",\""
                        + formName + "\");'>");
            }
            
            outStr.append("第一页");
            if (currentPageInt == 1)
            {
                outStr.append("</font>");
            }
            else
            {
                outStr.append("</a>");
            }
            
            outStr.append("</span>&nbsp;");
            outStr.append("<span style='cursor:hand'>");
            
            if (currentPageInt == 1)
            {
                outStr.append("<font color='#BBBBBB' size = '2'>");
            }
            else
            {
                outStr.append("<a href='javascript:goPage("
                        + (currentPageInt - 1) + "," + "\"" + actionName
                        + "\",\"" + methodName + "\",\"" + formName + "\")'>");
            }
            
            outStr.append("上一页");
            
            if (currentPageInt == 1)
            {
                outStr.append("</font>");
            }
            else
            {
                outStr.append("</a>");
            }
            
            outStr.append("</span>&nbsp;");
            outStr.append("<span style='cursor:hand'");
            outStr.append(">");
            
            if (currentPageInt == totalPageInt)
            {
                outStr.append("<font color='#BBBBBB' size = '2'>");
            }
            else
            {
                outStr.append("<a href='javascript:goPage("
                        + (currentPageInt + 1) + "," + "\"" + actionName
                        + "\",\"" + methodName + "\",\"" + formName + "\")'>");
            }
            
            outStr.append("下一页");
            
            if (currentPageInt == totalPageInt)
            {
                outStr.append("</font>");
            }
            else
            {
                outStr.append("</a>");
            }
            
            outStr.append("</span>&nbsp;");
            outStr.append("<span style='cursor:hand'>");
            
            if (currentPageInt == 1)
            {
                outStr.append("</font>");
            }
            else
            {
                outStr.append("</a>");
            }
            
            if (currentPageInt == totalPageInt)
            {
                outStr.append("<font color='#BBBBBB' size = '2'>");
            }
            else
            {
                outStr.append("<a href='javascript:goPage(" + totalPageInt
                        + "," + "\"" + actionName + "\",\"" + methodName
                        + "\",\"" + formName + "\")'>");
            }
            
            outStr.append("末页");
            
            if (currentPageInt == totalPageInt)
            {
                outStr.append("</font>");
            }
            else
            {
                outStr.append("</a>");
            }
            outStr.append("</span>&nbsp;");
        }
        
        outStr.append("&nbsp;共&nbsp;<Font color='#1E90FF' size='2'>");
        outStr.append(totalPageInt);
        outStr.append("</Font>&nbsp;页");
        
        outStr.append("<input type=\"hidden\" name=\"types\" value=\"0\" />");
        outStr.append("<input type=\"hidden\" name=\"firstLoad\" value=\"0\">");
        outStr.append("<input type=\"hidden\" name=\"first\" value=\"\">");
        outStr.append("<input type=\"hidden\" name=\"method\" value=\"\">");
        outStr.append("<input type=\"hidden\" name=\"command\" value=\"\">");
        outStr.append("<input type=\"hidden\" name=\"pageSize\" value=\"${pageSize}\">");
        outStr.append("<input type=\"hidden\" name=\"currentPage\" value=\"${currentPage}\">");
        outStr.append("<input type=\"hidden\" name=\"centrexid\" value=\"${requestScope.centrexid}\">");
        outStr.append("<input type=\"hidden\" name=\"groupid\" value=\"${requestScope.groupid}\">");
        
        out.println(outStr.toString());
        
    }
    
    /**
     * @return Returns the currentPage.
     */
    public String getCurrentPage()
    {
        return currentPage;
    }
    
    /**
     * @param currentPage
     *            The currentPage to set.
     */
    public void setCurrentPage(String currentPage)
    {
        this.currentPage = currentPage;
    }
    
    /**
     * @return Returns the formName.
     */
    public String getFormName()
    {
        return formName;
    }
    
    /**
     * @param formName
     *            The formName to set.
     */
    public void setFormName(String formName)
    {
        this.formName = formName;
    }
    
    /**
     * @return Returns the pageSize.
     */
    public String getPageSize()
    {
        return pageSize;
    }
    
    /**
     * @param pageSize
     *            The pageSize to set.
     */
    public void setPageSize(String pageSize)
    {
        this.pageSize = pageSize;
    }
    
    /**
     * @return Returns the selectPage.
     */
    public String getSelectPage()
    {
        return selectPage;
    }
    
    /**
     * @param selectPage
     *            The selectPage to set.
     */
    public void setSelectPage(String selectPage)
    {
        this.selectPage = selectPage;
    }
    
    /**
     * @return Returns the totalPage.
     */
    public String getTotalPage()
    {
        return totalPage;
    }
    
    /**
     * @param totalPage
     *            The totalPage to set.
     */
    public void setTotalPage(String totalPage)
    {
        this.totalPage = totalPage;
    }
    
    /**
     * @return Returns the actionName.
     */
    public String getActionName()
    {
        return actionName;
    }
    
    /**
     * @param actionName the actionName to set
     */
    public void setActionName(String actionName)
    {
        this.actionName = actionName;
    }
    
    /**
     * @return Returns the methodName.
     */
    public String getMethodName()
    {
        return methodName;
    }
    
    /**
     * @param methodName the methodName to set
     */
    public void setMethodName(String methodName)
    {
        this.methodName = methodName;
    }
}
